cmake_minimum_required(VERSION 3.6)  
project(LuaXML_lib)


find_package(luajit REQUIRED CONFIG)

# 获取当前目录下要编译的源文件  
file(GLOB_RECURSE SRC_FILES ${CMAKE_CURRENT_LIST_DIR}/*.c)

# 添加要编译的源文件  
if(BUILD_SHARED_LIBS)
	add_library(LuaXML_lib SHARED ${SRC_FILES})
else()
	add_library(LuaXML_lib STATIC ${SRC_FILES})
endif()

# 添加头文件搜索路径
target_include_directories(LuaXML_lib PUBLIC 
${CMAKE_CURRENT_LIST_DIR}
${luajit_INCLUDE_DIRS}
)
target_link_libraries(LuaXML_lib PUBLIC 
${luajit_LIBRARIES}
)

# 获取当前目录下的所有 .h 文件  
file(GLOB_RECURSE HEAD_FILES ${CMAKE_CURRENT_LIST_DIR}/*.h)

# 安装库文件  
install(TARGETS LuaXML_lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)  
install(FILES ${HEAD_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)